package com.fyzk.activity.user.redpacket;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by miao on 2017/4/23.
 */

public class ContactPhone {


    /**
     * +86去掉
     * @param phone
     * @return
     */
    public static String getNewPhone(String phone){
        if(!phone.equals("")&&phone.length()>3){
            if(phone.substring(0, 3).equals("+86")){
                phone = phone.substring(3, phone.length());
            }
        }
        return phone;
    }


    /**
     * 判断是否是手机号
     * @param phone
     * @return
     */
    public static boolean isPhone(String phone){
        phone = phone.replace(" ","");    // 除去空格
        if(!phone.equals("")){
            String phoneStr = getNewPhone(phone);
            Pattern p = Pattern.compile("^1(3|4|5|7|8)\\d{9}$");
            Matcher m = p.matcher(phoneStr);
            return m.matches();
        }else{
            return false;
        }
    }


    /**
     * 判断字符是否含有字母
     * @param str
     * @return
     */
    public static boolean isZiMu(String str){
        String regex=".*[a-zA-Z]+.*";
        Matcher m=Pattern.compile(regex).matcher(str);
        return m.matches();
    }

}
